import CompConfig from '@/utils/CompConfig'
const {CompTypeConfig} = CompConfig

let requireComponent = require.context(
    './', // 在当前目录下查找
    false, // 不遍历子文件夹
    /\.vue$/ // 正则匹配 以 .vue结尾的文件
)
let compList = []
requireComponent.keys().forEach(fileName => {
    let comp = requireComponent(fileName).default
	compList.push(comp)
})

let compObj = {}
compList.forEach(comp => {
	let compType = comp.type
	let compTypeObj = CompTypeConfig[compType]
	if (!compTypeObj) return
	let compTypeList = {...(compObj[compType] || {}), ...compTypeObj}
	let comps = compTypeList['comps'] || {}
	comps[comp.name] = comp
	compTypeList['comps'] = comps
	compObj[compType] = compTypeList
})

export default compObj
